local M = require "packages/mamashengde/record/Made"

local shengcai = fk.CreateSkill {
  name = "shine__shengcai",
}

Fk:loadTranslationTable {
  ["shine__shengcai"] = "圣裁",
  [":shine__shengcai"] = "出牌阶段，你可消耗任意魔力，将等量张手牌当做无距离次数限制的【杀】使用，你以此法使用的【杀】造成的伤害+X（X为你本次消耗的魔力数）。",

  ["#shengcai"] = "圣裁：你可以将任意张手牌当【杀】使用（消耗等量魔力），无距离与次数限制且增加等量伤害",
}

shengcai:addEffect("viewas", {
  anim_type = "offensive",
  pattern = "slash",
  prompt = "#shengcai",
  handly_pile = true,
  filter_pattern = function (self, player, card_name)
    local x = M.getMaryoku(player)
    return {
      max_num = x,
      min_num = 1,
      pattern = ".|.|.|^equip",
    }
  end,
  view_as = function(self, player, cards)
    if #cards < 1 then return end
    local c = Fk:cloneCard("slash")
    c.skillName = shengcai.name
    c:addSubcards(cards)
    return c
  end,
  before_use = function(self, player, use)
    local num = #use.card.subcards
    M.changeMaryoku(player, -num, shengcai.name)
    use.additionalDamage = (use.additionalDamage or 0) + math.max(num, 1)
  end,
  enabled_at_play = function(self, player)
    return M.getMaryoku(player) > 0
  end,
  enabled_at_response = Util.FalseFunc,
})

shengcai:addEffect("targetmod", {
  bypass_distances = function(self, player, skill, card, to)
    return card and table.contains(card.skillNames, shengcai.name)
  end,
  bypass_times = function (self, player, skill, scope, card, to)
    return card and table.contains(card.skillNames, shengcai.name)
  end,
})

return shengcai